<body>
    <iframe name="exportFram" id="exportFrame" src="" style="display: none;"></iframe>
    <form id="my-form">
        <div id="tools" class="datagrid-toolbar">
            <input type="hidden" name="type" id="type" value="22">
            <a id="subBtn" name="subOk" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-save"
                plain="true"><span class="l-btn-left"><span
                        class="l-btn-text icon-save l-btn-icon-left">保存</span></span></a>
            <a class="easyui-linkbutton l-btn l-btn-plain" id="commitBtn" iconcls="icon-redo" plain="true"
                onclick="commit();" style="display:none"><span class="l-btn-left"><span
                        class="l-btn-text icon-redo l-btn-icon-left">提交</span></span></a>
            <a id="closeBtn" name="backOk" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-close"
                plain="true"><span class="l-btn-left"><span
                        class="l-btn-text icon-close l-btn-icon-left">关闭</span></span></a>
        </div>
        <p id="errorMsg" style="color:red;margin-top:5px;"></p>
        <table class="formTable">
            <tbody>
                <tr>
                    <td class="tdc1" style="width:180px;">
                        申请人：
                    </td>
                    <td>
                        <input type="text" name="applyUserName" id="applyUserName" data-options="required:true"
                            class="easyui-validatebox texfind validatebox-text" readonly="">
                        <input type="hidden" name="applyUserId" id="applyUserId">
                        <a class="easyui-linkbutton l-btn l-btn-plain" id="clear0" iconcls="icon-undo" plain="true"
                            onclick="clearCheck('applyUserName,applyUserId');"><span class="l-btn-left"><span
                                    class="l-btn-text icon-undo l-btn-icon-left">清除</span></span></a>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        装修工程需求申请表：
                    </td>
                    <td>
                        <input type="text" name="decorateProjectName" id="decorateProjectName"
                            data-options="required:true" class="easyui-validatebox texfind validatebox-text"
                            readonly="">
                        <input type="hidden" name="decorateProjectId" id="decorateProjectId">
                        <a class="easyui-linkbutton l-btn l-btn-plain" id="clear1" iconcls="icon-undo" plain="true"
                            onclick="clearDecorateProject();"><span class="l-btn-left"><span
                                    class="l-btn-text icon-undo l-btn-icon-left">清除</span></span></a>
                        <span style="margin-left:2px;" id="toView"></span>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        前置审批：
                    </td>
                    <td>
                        <input type="text" name="approvalNames" id="approvalNames" value="王博宇"
                            class="easyui-validatebox texfind validatebox-text" readonly="">
                        <input type="hidden" name="approvalIds" id="approvalIds" value="572">
                        <a class="easyui-linkbutton l-btn l-btn-plain" id="clear2" iconcls="icon-undo" plain="true"
                            onclick="clearCheck('approvalNames,approvalIds');"><span class="l-btn-left"><span
                                    class="l-btn-text icon-undo l-btn-icon-left">清除</span></span></a>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        总经理：
                    </td>
                    <td>
                        <input type="text" name="managername" id="managername"
                            class="easyui-validatebox texfind validatebox-text" readonly="">
                        <input type="hidden" name="managerid" id="managerid">
                        <a class="easyui-linkbutton l-btn l-btn-plain" id="clear3" iconcls="icon-undo" plain="true"
                            onclick="clearCheck('managername,managerid');"><span class="l-btn-left"><span
                                    class="l-btn-text icon-undo l-btn-icon-left">清除</span></span></a>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        董事长：
                    </td>
                    <td>
                        <input type="text" name="presidentname" id="presidentname"
                            class="easyui-validatebox texfind validatebox-text" readonly="">
                        <input type="hidden" name="presidentid" id="presidentid">
                        <a class="easyui-linkbutton l-btn l-btn-plain" id="clear4" iconcls="icon-undo" plain="true"
                            onclick="clearCheck('presidentname,presidentid');"><span class="l-btn-left"><span
                                    class="l-btn-text icon-undo l-btn-icon-left">清除</span></span></a>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        备注：
                    </td>
                    <td>
                        <textarea name="remark" id="remark" style="width:732px;height:70px"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        上传附件模板：
                    </td>
                    <td>
                        <a style="margin-left:5px;" href="javascript:void(0);" onclick="myDownload(1)">供应商分项报价.xls</a>
                        <a style="margin-left:15px;" href="javascript:void(0);" onclick="myDownload(2)">供应商报价清单.xls</a>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1" colspan="2" style="text-align:left;padding-left:55px;font-weight:bold;">
                        供应商1：
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        公司名称：
                    </td>
                    <td>
                        <input type="text" name="companyname1" id="companyname1" data-options="required:true"
                            class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        总报价：
                    </td>
                    <td>
                        <input type="text" id="money1" data-options="required:true"
                            class="easyui-numberbox numberbox-f validatebox-text" precision="2"
                            numberboxname="money1"><input type="hidden" name="money1" value="">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        供应商联系人、联系方式：
                    </td>
                    <td>
                        <input type="text" name="linkman1" id="linkman1" data-options="required:true"
                            class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        供应商情况简介、资质：
                    </td>
                    <td>
                        <textarea name="describes1" id="describes1" style="width:732px;height:70px"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        供应商方案、报价清单：
                    </td>
                    <td>
                        <input type="hidden" name="objectId" id="objectId" value="1761792602855">
                        <div id="easyContainer"><input type="file" multiple="" class="fileInput"
                                style="display:none;"><a class="formBtn" id="btu_" style="color:#8C8686;"
                                href="javascript:void(0);">上传</a>
                            <div class="flist" style="margin-top: 0px;"></div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1" colspan="2" style="text-align:left;padding-left:55px;font-weight:bold;">
                        供应商2：
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        公司名称：
                    </td>
                    <td>
                        <input type="text" name="companyname2" id="companyname2"
                            class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        总报价：
                    </td>
                    <td>
                        <input type="text" id="money2" class="easyui-numberbox numberbox-f validatebox-text"
                            precision="2" numberboxname="money2"><input type="hidden" name="money2" value="">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        供应商联系人、联系方式：
                    </td>
                    <td>
                        <input type="text" name="linkman2" id="linkman2" class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        供应商情况简介、资质：
                    </td>
                    <td>
                        <textarea name="describes2" id="describes2" style="width:732px;height:70px"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        供应商方案、报价清单：
                    </td>
                    <td>
                        <input type="hidden" name="objectId1" id="objectId1" value="1761792602856">
                        <div id="easyContainer1"><input type="file" multiple="" class="fileInput"
                                style="display:none;"><a class="formBtn" id="btu_" style="color:#8C8686;"
                                href="javascript:void(0);">上传</a>
                            <div class="flist" style="margin-top: 0px;"></div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1" colspan="2" style="text-align:left;padding-left:55px;font-weight:bold;">
                        供应商3：
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        公司名称：
                    </td>
                    <td>
                        <input type="text" name="companyname3" id="companyname3"
                            class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        总报价：
                    </td>
                    <td>
                        <input type="text" id="money3" class="easyui-numberbox numberbox-f validatebox-text"
                            precision="2" numberboxname="money3"><input type="hidden" name="money3" value="">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        供应商联系人、联系方式：
                    </td>
                    <td>
                        <input type="text" name="linkman3" id="linkman3" class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        供应商情况简介、资质：
                    </td>
                    <td>
                        <textarea name="describes3" id="describes3" style="width:732px;height:70px"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        供应商方案、报价清单：
                    </td>
                    <td>
                        <input type="hidden" name="objectId2" id="objectId2" value="1761792602857">
                        <div id="easyContainer2"><input type="file" multiple="" class="fileInput"
                                style="display:none;"><a class="formBtn" id="btu_" style="color:#8C8686;"
                                href="javascript:void(0);">上传</a>
                            <div class="flist" style="margin-top: 0px;"></div>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>


    <script>
        initSelect(1);//初始化选人框；1：默认根据部门

        initSelectDept();//初始化选择部门

        $("#applyUserName").click(function () {
            showSelect('applyUserName,applyUserId', 'text,id', '');
        });

        $("#applyDeptName").click(function () {
            showSelectDept('applyDeptName,applyDeptId', 'text,id', '');
        });

        $("#decorateProjectName").click(function () {
            parent.addTabs("选择需求申请表", contextPath + "system/qdzxapproval/approval/select_decorateproject.html?_pfrid=" + $.getUrlParam("_frid"));
        });

        function setParams(id, name) {
            $("#decorateProjectName").val(name);
            $("#decorateProjectId").val(id);
            var txt = "<a href=\"javascript:viewDecorateProject(" + id + ");\">查看详情</a>";
            $("#toView").html(txt);
        }

        function viewDecorateProject(id) {
            var msg = "装修工程需求申请表";
            var url = "decorateproject_view.html?id=" + id;
            parent.addTabs("查看" + msg + "-" + id, contextPath + "system/qdzxapproval/approval/" + url + "&_pfrid=" + $.getUrlParam("_frid"));
        }

        function clearDecorateProject() {
            $("#decorateProjectName").val("");
            $("#decorateProjectId").val("");
            $("#toView").html("");
        }

        $("#approvalNames").click(function () {
            showSelect('approvalNames,approvalIds', 'text,id', 'checkAny');
        });

        $("#managername").click(function () {
            showSelect('managername,managerid', 'text,id', '');
        });

        $("#presidentname").click(function () {
            showSelect('presidentname,presidentid', 'text,id', '');
        });

        function myDownload(type) {
            if (type == 1) {
                $("#exportFrame").attr("src", contextPath + "system/template/供应商分项报价.xls");
            } else {
                $("#exportFrame").attr("src", contextPath + "system/template/供应商报价清单.xls");
            }
        }

        function checkFormMe(form) {
            var companyname2 = $("#companyname2").val();
            if (companyname2 != null && companyname2 != "") {
                var money2 = $("#money2").val();
                var linkman2 = $("#linkman2").val();
                if (money2 == null || money2 == "" || linkman2 == null || linkman2 == "") {
                    $.messager.alert("提示", "输入供应商公司名称后，必须输入对应的报价、联系人、联系方式", 'info');
                    return false;
                }
            }
            var companyname3 = $("#companyname3").val();
            if (companyname3 != null && companyname3 != "") {
                var money3 = $("#money3").val();
                var linkman3 = $("#linkman3").val();
                if (money3 == null || money3 == "" || linkman3 == null || linkman3 == "") {
                    $.messager.alert("提示", "输入供应商公司名称后，必须输入对应的报价、联系人、联系方式", 'info');
                    return false;
                }
            }
            return $('#my-form').form('validate');
        }

        var type = $.getUrlParam("type");

        $("#type").val(type);

        var p_id = $.getUrlParam("id");

        var objectId = new Date().getTime();
        var objectId1 = parseInt(objectId) + 1;
        var objectId2 = parseInt(objectId) + 2;

        $("#objectId").val(objectId);
        $("#objectId1").val(objectId1);
        $("#objectId2").val(objectId2);

        var BaseModel = Backbone.Model.extend({ urlRoot: contextPath + 'manager/projectSupplier' });
        var baseModel;

        if (p_id == null) {
            baseModel = new BaseModel();
        } else {
            baseModel = new BaseModel({ id: p_id, i: new Date().getTime() });
        }
        var baseView = new BaseView({ el: $("#my-form"), model: baseModel });

        //附件
        $('#easyContainer').easyUpload({
            fileTypes: 'all',//all,image,file
            selectText: "上传",//上传按钮文案
            multi: true,//是否允许多文件上传  
            maxNum: 20,//文件上传最大个数
            maxNote: '最多可以上传20个文件，已超出最大上传个数，无法上传！',
            showType: "flist",//展示方。flist,imglist
            fileNote: '文件格式错误，只能上传以下格式',//文件上传说明
            url: contextPath + 'affix',//上传文件地址
            ajaxType: 'POST',//POST,GET
            fileName: 'file',//文件配置参数
            timeout: 300000,//请求超时时间
            formParam: { "objectId": objectId, "objectType": 211 },
        });
        //附件
        $('#easyContainer1').easyUpload({
            fileTypes: 'all',//all,image,file
            selectText: "上传",//上传按钮文案
            multi: true,//是否允许多文件上传  
            maxNum: 20,//文件上传最大个数
            maxNote: '最多可以上传20个文件，已超出最大上传个数，无法上传！',
            showType: "flist",//展示方。flist,imglist
            fileNote: '文件格式错误，只能上传以下格式',//文件上传说明
            url: contextPath + 'affix',//上传文件地址
            ajaxType: 'POST',//POST,GET
            fileName: 'file',//文件配置参数
            timeout: 300000,//请求超时时间
            formParam: { "objectId": objectId1, "objectType": 212 },
        });
        //附件
        $('#easyContainer2').easyUpload({
            fileTypes: 'all',//all,image,file
            selectText: "上传",//上传按钮文案
            multi: true,//是否允许多文件上传  
            maxNum: 20,//文件上传最大个数
            maxNote: '最多可以上传20个文件，已超出最大上传个数，无法上传！',
            showType: "flist",//展示方。flist,imglist
            fileNote: '文件格式错误，只能上传以下格式',//文件上传说明
            url: contextPath + 'affix',//上传文件地址
            ajaxType: 'POST',//POST,GET
            fileName: 'file',//文件配置参数
            timeout: 300000,//请求超时时间
            formParam: { "objectId": objectId2, "objectType": 213 },
        });

        function success(model, response, options) {
            var data = model.get("handleMsg");
            $.messager.alert('提示', model.get("handleMsg").message, 'info', function (rt) {
                if (data.status == 1) {
                    //图层解锁
                    //$("#myForm").unblock();
                    var subtitle = encodeURI(encodeURI($.getUrlParam("subtitle")));
                    window.parent.frames["" + $.getUrlParam("_pfrid")].location.reload();
                    window.location.href = contextPath + "system/qdzxapproval/approval/projectsupplier_edit.html?type=22&processid=" + model.get("id") + "&_pfrid=" + $.getUrlParam("_pfrid") + "&_frid=" + $.getUrlParam("_frid") + "&subtitle=" + subtitle;
                } else {
                    $("#errorMsg").html(data.message);
                    //图层解锁
                    //$("#myForm").unblock();
                }
            });
        }

    </script>
    <div class="panel window" style="display: none; width: 450px; left: 425.5px; top: 25px;">
        <div class="panel-header panel-header-noborder window-header" style="width: 450px;">
            <div class="panel-title panel-with-icon">根据部门选择</div>
            <div class="panel-icon icon-manager"></div>
            <div class="panel-tool"><a class="panel-tool-collapse" href="javascript:void(0)"></a><a
                    class="panel-tool-close" href="javascript:void(0)"></a></div>
        </div>
        <div id="selectMan" class="easyui-window panel-body panel-body-noborder window-body" title=""
            data-options="closed:true,modal:true,iconCls:'icon-manager',minimizable:false,maximizable:false"
            style="z-index: 301; width: 450px; height: 325px;">
            <div id="selectManHead" class="datagrid-toolbar"><a class="easyui-linkbutton l-btn l-btn-plain"
                    iconcls="icon-ok" plain="true" onclick="checkSelectMan();" id=""><span class="l-btn-left"><span
                            class="l-btn-text icon-ok l-btn-icon-left">选择</span></span></a><a
                    class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-reload" plain="true"
                    onclick="reload_data();" id=""><span class="l-btn-left"><span
                            class="l-btn-text icon-reload l-btn-icon-left">刷新</span></span></a><a
                    class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-close" plain="true"
                    onclick="closeSelectMan();" id=""><span class="l-btn-left"><span
                            class="l-btn-text icon-close l-btn-icon-left">关闭</span></span></a></div>
            <div id="menu_tree" class="easyui-tree tree tree-lines" style="margin-top:35px;z-index: 300;"
                data-options="animate:true,lines:true,checkbox:true"></div>
        </div>
    </div>
    <div class="window-shadow" style="display: none; left: 425.5px; top: 25px;"></div>
    <div class="window-mask" style="width: 1301px; height: 1025px; display: none;"></div>
    <div class="panel window" style="display: none; width: 350px; left: 475.5px; top: 10px;">
        <div class="panel-header panel-header-noborder window-header" style="width: 350px;">
            <div class="panel-title panel-with-icon">部门选择</div>
            <div class="panel-icon icon-manager"></div>
            <div class="panel-tool"><a class="panel-tool-collapse" href="javascript:void(0)"></a><a
                    class="panel-tool-close" href="javascript:void(0)"></a></div>
        </div>
        <div id="selectDept" class="easyui-window panel-body panel-body-noborder window-body" title=""
            data-options="closed:true,modal:true,iconCls:'icon-manager',minimizable:false,maximizable:false"
            style="width: 350px; height: 355px;">
            <div class="datagrid-toolbar"><a class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-ok" plain="true"
                    onclick="checkSelectDept();" id=""><span class="l-btn-left"><span
                            class="l-btn-text icon-ok l-btn-icon-left">选择</span></span></a><a
                    class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-reload" plain="true"
                    onclick="reload_data_dept();" id=""><span class="l-btn-left"><span
                            class="l-btn-text icon-reload l-btn-icon-left">刷新</span></span></a><a
                    class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-close" plain="true"
                    onclick="closeSelectDept();" id=""><span class="l-btn-left"><span
                            class="l-btn-text icon-close l-btn-icon-left">关闭</span></span></a></div>
            <div id="menu_tree_dept" class="easyui-tree tree tree-lines"
                data-options="animate:true,lines:true,checkbox:true"></div>
        </div>
    </div>
    <div class="window-shadow" style="display: none; left: 475.5px; top: 10px;"></div>
    <div class="window-mask" style="width: 1301px; height: 1025px; display: none;"></div>
</body>